package org.yly.game.rpggame.domain.model.skill;

import java.util.HashSet;
import java.util.Set;

import org.yly.game.rpggame.domain.model.CustomProperty;
import org.yly.game.rpggame.domain.model.TargetType;
import org.yly.game.rpggame.domain.model.UpgradeEntity;

/**
 * 技能
 * 
 * @author makefu
 * 
 */
public class Skill extends UpgradeEntity {

	/* 基本信息 */
	private String name;
	private String description; 
	private int cdTime; // 冷却时间
	private int radius; // 作用范围
	
	/* 开放限制 */
	private int playerLevel; // 玩家等级
	private int skillPoint; // 技能点数

	public Skill(String id, String name, String description, int cdTime, int radius,
			Set<SkillProperty> propertySet) {
		super(id, propertySet);
		this.name = name;
		this.description = description;
		this.cdTime = cdTime;
		this.radius = radius;
	}
	/**
	 * 获得技能属性
	 * @param targetType 指定目标
	 * @return
	 */
	public Set<CustomProperty> getProperty(TargetType targetType){
		Set<CustomProperty> set = new HashSet<CustomProperty>();
		for (CustomProperty property : this.getPropertySet()){
			set.add(property);
		}
		return set;
	}
	
	/**
	 * 技能释放开放
	 * @param playerLevel
	 * @param skillPoint
	 * @return
	 */
	public boolean isOpen(int playerLevel, int skillPoint) {
		return playerLevel >= this.playerLevel && skillPoint >= this.skillPoint;
	}
	
	public String getName() {
		return name;
	}

	public String getDescription() {
		return description;
	}

	public int getCdTime() {
		return cdTime;
	}

	public int getRadius() {
		return radius;
	}
}
